@inherits LayoutComponentBase

@inject IStringLocalizer<SharedResource> L
<MudRTLProvider RightToLeft="@LayoutService.IsRTL">
<MudDialogProvider />
<MudSnackbarProvider />
<MudThemeProvider @ref="@_mudThemeProvider"  Theme="@LayoutService.CurrentTheme" IsDarkMode="@LayoutService.IsDarkMode" IsDarkModeChanged="LayoutService.SetDarkMode" />
<UserLoginState />
<MudLayout>
    <AuthorizeView>
        <NotAuthorized>
            <MudContainer MaxWidth="MaxWidth.Small" Class="d-flex align-center" Style="height: 100vh;">
                <div class="d-flex flex-column mud-width-full">
                    <MudPaper Elevation="25" Class="pa-8" Width="100%" MaxWidth="500px">
                        <MudIcon Icon="@Icons.Custom.Brands.MudBlazor" Size="Size.Large" Style="width:100px; height:100px;" />
                        @Body
                    </MudPaper>
                    <MudAlert Severity="MudBlazor.Severity.Info" Class="mt-8 mud-width-full" Style="max-width:500px;">@L["authentication is required, click sign in."]</MudAlert>
                </div>
            </MudContainer>
        </NotAuthorized>
        <Authorized>
            <NavMenu SideMenuDrawerOpen="_sideMenuDrawerOpen"
                     OpenCommandPalette="OpenCommandPalette"
                     IsDarkMode="@LayoutService.IsDarkMode"
                     ToggleSideMenuDrawer="ToggleSideMenuDrawer"
                     RightToLeft="@LayoutService.IsRTL"
                     RightToLeftToggle ="LayoutService.ToggleRightToLeft"
                     OnSettingClick="@(() => _themingDrawerOpen = true)"
                     User="@_profileService.Profile" />

            <SideMenu SideMenuDrawerOpen="_sideMenuDrawerOpen"
                      SideMenuDrawerOpenChanged="SideMenuDrawerOpenChangedHandler"
                      User="@_profileService.Profile" />

            <ThemesMenu ThemingDrawerOpen="_themingDrawerOpen"
                        ThemingDrawerOpenChanged="ThemingDrawerOpenChangedHandler"
                        UserPreferences="UserPreferences"
                        UserPreferencesChanged="LayoutService.UpdateUserPreferences" />
            <ThemesButton OnClick="@(() => _themingDrawerOpen = true)" />

            <MudMainContent>
                <MudContainer MaxWidth="MaxWidth.ExtraLarge" Class="mb-4 mt-4">
                    @Body
                </MudContainer>
            </MudMainContent>
        </Authorized>
    </AuthorizeView>
</MudLayout>
</MudRTLProvider>
